package ru.jexp.utilities.collections;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class MapList<K, V> {

	private Map<K, List<V>> container;

	public MapList() {
		this(new HashMap<K, List<V>>());
	}

	public MapList(Map<K, List<V>> container) {
		this.container = container;
	}

	public void put(K key, List<V> list) {
		container.put(key, list);
	}

	public void put(K key, V value) {
		if (get(key) == null) {
			put(key, new ArrayList<V>());
		}
		get(key).add(value);
	}

	public List<V> get(K key) {
		return container.get(key);
	}

	public Set<K> keySet() {
		return container.keySet();
	}

	public Collection<List<V>> values() {
		return container.values();
	}

	public void remove(K key) {
		if (container.keySet().contains(key)) {
			container.remove(key);
		}
	}
	
	public void clear()
	{
		container.clear();
	}
}
